import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../components/index'
import Test from '../components/test'
import Home from '../views/home/index'
//mobile
import test_bs from "../components/mobile/common/scroll/test-bs"
import Index_m from "../components/mobile/index_m";
import Home_m from "../components/mobile/home_m";
import music from "../components/mobile/music/Music_m";
import book from "../components/mobile/book/book";
import movie from "../components/mobile/movie/movie";
import cartoon from "../components/mobile/cartoon/cartoon";
import Content from "../components/mobile/common/content/content";
import check_m from "../components/mobile/common/check/check_m";
Vue.use(VueRouter);

const routes = [
  {
    path: '/index',
    name: 'Index',
    component: Index
  },
  {
    path: '/test',
    name: 'Test',
    component: Test
  },
  {
    path:'/home/index',
    name:'home',
    component:Home
  },
  //mobile
  {
    path:"/test_bs",
    component:test_bs
  },
  {
    path:"/mobile",
    name : "Mobile",
    component:Index_m
  },
  {
    path:"/mobile/home",
    name:"Home_m",
    redirect:"/mobile/home/music",
    component:Home_m,
    children:[
      {
        path: 'book',
        component: book,
      },
      {
        path: "book/:id",
        component: Content
      },

      {
        path: 'music',
        component: music,
      },
      {
        path: "music/:id",
        component: Content
      },
      {
        path:'music/name/:names',
        component:check_m,
        beforeLeave(to,from,next){
          check_m.data.list = [];
          next()
        }
      },

      {
        path: 'cartoon',
        component: cartoon,
      },
      {
        path: "cartoon/:id",
        component: Content
      },

      {
        path: 'movie',
        component: movie,
      },
      {
        path: "movie/:id",
        component: Content
      }
    ]
  }
];

const router = new VueRouter({
  mode:'history',
  base: '/',  // 基础路径
  routes,

});

export default router
